package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.io.*;
import java.util.*;
import beans.BeanLoginUser;
import mapping.Idioma;
import mapping.Usuario;

public final class misdatos_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.List _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.AnnotationProcessor _jsp_annotationprocessor;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
  }

  public void _jspDestroy() {
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html; charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			"error/errorpage.jsp", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write('\n');
      out.write('\n');
      out.write('\n');
      beans.BeanLoginUser mybean = null;
      synchronized (_jspx_page_context) {
        mybean = (beans.BeanLoginUser) _jspx_page_context.getAttribute("mybean", PageContext.PAGE_SCOPE);
        if (mybean == null){
          mybean = new beans.BeanLoginUser();
          _jspx_page_context.setAttribute("mybean", mybean, PageContext.PAGE_SCOPE);
        }
      }
      out.write("\n");
      out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n");
      out.write("<!-- VALIDADO!! :-D -->\n");

	if(session.getAttribute("usuario") == null){
		throw new IllegalArgumentException("Oye! No intentes acceder a esta pagina sin haberte logueado antes.<br/>"+ 
		"Si ya te logueaste es posible que tu sesion haya expirado; en ese caso, vuelve a introducir tu usuario y contrase&ntilde;a"
		+"<br/>Haz click <a href='index.jsp'>aqu&iacute;</a>");
	}
	String id = session.getId();
	String usuario = (String) session.getAttribute("usuario");
	String id_usuario = (String) session.getAttribute("id_usuario");

      out.write("\n");
      out.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
      out.write("<head>\n");
      out.write("\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n");
      out.write("\t<link rel=\"stylesheet\" href=\"estilos/style.css\" type=\"text/css\" media=\"screen\" charset=\"utf-8\" />\t\n");
      out.write("\t<script src =\"ajax/scriptaculous-js-1.8.1/lib/prototype.js\"  type=\"text/javascript\" charset=\"utf-8\"></script>\n");
      out.write("\t<script src =\"ajax/scriptaculous-js-1.8.1/src/effects.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n");
      out.write("\t<script src=\"ajax/ajax_login.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n");
      out.write("\t<script src=\"ajax/ajax_utils.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n");
      out.write("\t<script src=\"js/menu.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n");
      out.write("\t<title>Erasmus Help! - Mis datos</title>\n");
      out.write("</head>\n");
      out.write("<body onload = \"ocultaSubMenu()\">\n");
      out.write("\t");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "hidden.jsp", out, false);
      out.write("\n");
      out.write("\t<div id='page_wrapper'>\n");
      out.write("\t\n");
      out.write("\t");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "cabecera.jsp", out, false);
      out.write("\n");
      out.write("\t\n");
      out.write("\t");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "menu_user.jsp", out, false);
      out.write("\n");
      out.write("\t\n");
      out.write("\t<div id='content_wrapper'>\n");
      out.write("\n");
      out.write("\t<div id=\"contenido\">\n");
      out.write("\t");

	mybean.conectar(); 
	Usuario user = mybean.getUsuario(id_usuario);
	
      out.write(" \n");
      out.write("\t<div id=\"wrapper_misdatos\">\n");
      out.write("\t\t<form action=\"#\" id=\"form_reg_user\"  onsubmit=\"return false;\" accept-charset=\"UTF-8\">\n");
      out.write("\t\t<fieldset>\n");
      out.write("\t\t<legend>Mis datos&nbsp;</legend>\n");
      out.write("\t\t\t<div class=\"spacer\"></div>\n");
      out.write("\t\t\t<div class=\"divreg\" style=\"float: left\">\n");
      out.write("\t\t\t\t<label for=\"user\">Usuario*</label>\n");
      out.write("\t\t\t\t<input type=\"text\" id=\"user\" name=\"user\" value = \"");
      out.print(user.getUsuario());
      out.write("\" \n");
      out.write("\t\t\t\tmaxlength=\"50\" title=\"Introduzca el nuevo nombre de usuario de gmail\"/>\n");
      out.write("\t\t\t\t<span>@gmail.com</span>\n");
      out.write("\t\t\t\t<input type=\"hidden\" id=\"id_usuario\" name=\"id_usuario\" value=\"");
      out.print(id_usuario);
      out.write("\"/>\n");
      out.write("\t\t\t</div><!--  fin divreg -->\n");
      out.write("\t\t\t\t\n");
      out.write("\t\t\t<div id=\"capaidioma\"><label for=\"idioma\">Idioma*</label>\n");
      out.write("\t\t\t\t<select id=\"idioma\" name=\"idioma\" title=\"Selecciona el idioma\">\n");
      out.write("\t\t\t\t\t");

					List listaIdiomas = mybean.getIdiomas();
					Iterator it = listaIdiomas.iterator();
					while(it.hasNext()){
						String [] idiomas = ((String) it.next()).split(",");
						if(!idiomas[0].equals(user.getId_idioma())){
						
      out.write("\n");
      out.write("\t\t\t\t\t\t\t<option value = \"");
      out.print(idiomas[0]);
      out.write('"');
      out.write('>');
      out.print(idiomas[1]);
      out.write("</option>\n");
      out.write("\t\t\t\t\t\t");
}
						else{
      out.write("\n");
      out.write("\t\t\t\t\t\t\t<option selected=\"selected\" value = \"");
      out.print(idiomas[0]);
      out.write('"');
      out.write('>');
      out.print(idiomas[1]);
      out.write("</option>\n");
      out.write("\t\t\t\t\t\t");
}	
					}//fin while
				
      out.write("\n");
      out.write("\t\t\t\t </select>\n");
      out.write("\t\t   </div><!--  fin capaidioma -->\n");
      out.write("\t\t   <div class=\"divreg\">\n");
      out.write("\t\t\t\t<label for=\"nombre\">Nombre*</label>\n");
      out.write("\t\t\t\t<input type=\"text\" id=\"nombre\" name=\"nombre\" value=\"");
      out.print(user.getNombre());
      out.write("\" maxlength=\"50\" title=\"Nombre\"/> \n");
      out.write("\t\t\t</div>\n");
      out.write("\t\t\t        \n");
      out.write("\t\t\t<div class=\"divreg\">\n");
      out.write("\t\t\t\t<label for=\"apell\">Apellidos</label>\n");
      out.write("\t\t\t\t<input type=\"text\" id=\"apell\" name=\"apell\" value = \"");
      out.print(user.getApellidos());
      out.write("\" maxlength=\"50\" size=\"30\" title=\"Apellidos\"/> \n");
      out.write("\t\t\t</div>\n");
      out.write("\t\t\t<div class=\"divreg\">\n");
      out.write("\t\t\t\t<label for=\"email\">e-mail</label>\n");
      out.write("\t\t\t\t<input type=\"text\" id=\"email\" name=\"email\" value = \"");
      out.print(user.getEmail());
      out.write("\" maxlength=\"50\" size=\"30\" title=\"Introduzca su nuevo e-mail\"/> \n");
      out.write("\t\t\t</div>\t\t\t\n");
      out.write("\t\t\t<div class=\"spacer\"></div>\t\n");
      out.write("\t\t\t<div id=\"capabotones\" class=\"centrado\">\n");
      out.write("\t\t\t\t<button class=\"mybtn\" onmouseover=\"goLite(this)\" onmouseout=\"goDim(this)\" \n");
      out.write("\t\t\t\tonclick=\"history.back();\">Cancelar</button>\t\t\t\t\n");
      out.write("\t\t\t\t<button id=\"btInsEnlace\" class=\"mybtn\" onmouseover=\"goLite(this)\" onmouseout=\"goDim(this)\"\n");
      out.write("\t\t\t\tonclick=\"procesaParametros('res_insert', 'form_reg_user', 'proc_actualiza_usuario.jsp', 'post')\" title=\"Pulse aqu&iacute; para guardas sus datos\">Guardar</button>\n");
      out.write("\t\t\t</div>\n");
      out.write("\t\t</fieldset>\t\t\t\n");
      out.write("\t\t</form>\n");
      out.write("\t<div id=\"res_insert\"></div>\t\t\n");
      out.write("\t</div> <!-- fin wrapper_misdatos -->\n");
      out.write("\t\t<div class='spacer'></div> \n");
      out.write("\t\t<div class='spacer'></div> \n");
      out.write("</div><!-- fin <div id=\"contenido\"> -->\n");
      out.write("\n");
      out.write("</div> <!--fin  <div id='content_wrapper'> -->\n");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "pie.html", out, false);
      out.write("\n");
      out.write("</div> <!-- <div id='page_wrapper'> -->\n");
      out.write("</body>\n");
      out.write("</html>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
